package com.itheima.pojo;

import lombok.Getter;

/**
 * 订单状态枚举
 */
@Getter
public enum OrderStatus {
    PENDING("pending", "待付款"),
    PAID("paid", "已付款"),
    SHIPPED("shipped", "已发货"),
    COMPLETED("completed", "已完成"),
    CANCELLED("cancelled", "已取消"),
    REFUNDING("refunding", "退款中"),
    REFUNDED("refunded", "已退款");

    private final String value;
    private final String description;

    OrderStatus(String value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * 判断订单状态是否可以取消
     */
    public static boolean canCancel(String status) {
        return PENDING.getValue().equals(status) || 
               PAID.getValue().equals(status);
    }

    /**
     * 判断订单状态是否可以申请退款
     */
    public static boolean canApplyRefund(String status) {
        return PAID.getValue().equals(status) || 
               SHIPPED.getValue().equals(status) || 
               COMPLETED.getValue().equals(status);
    }
}